package com.bjc.controller;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @program: servlet
 * @description:
 * @author: bjc
 * @create: 2021-08-18 21:18
 */
public class OneServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //读取请求行中url信息
        String url = req.getRequestURL().toString();
        //通过请求对象 读取请求行中的method信息
        String method = req.getMethod();
        System.out.println("url:"+url);
        System.out.println("method:"+method);

        /**
         * 通过请求对象 读取请求行中的URI信息
         *  实际上url中截取一个字符串，这个字符串格式”/网名/资源文件名“
         *  URI用于让Http服务器对被访问的资源文件进行定位
         */
        String requestURI = req.getRequestURI();
        System.out.println("URI:"+requestURI);
    }
}
